package cn.rongdao.jrkabao.ui.IdentificationVerificate.IdentificationWithValidationItem.status;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.mifengkong.frtools.ui.activity.FRStartActivity;
import com.mifengkong.frtools.ui.statusbar.FRStatusBar;
import com.mifengkong.frwidget.titlebar.TitleBarUIComponent;
import com.mifengkong.greendao.bean.FundAndActivityCenterUrlBean;

import butterknife.BindView;
import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.bean.loan.ApplySuccessBean;
import cn.rongdao.jrkabao.constant.InfoConstant;
import cn.rongdao.jrkabao.dao.FundAndActivityCenterUrlDao;
import cn.rongdao.jrkabao.ui.webview.WebViewActivity;

/**
 * Created by jiangyongxing on 2017/9/20.
 * 描述：失败界面
 */

public class StatusForNonCompliantActivity extends StatusBaseActivity {

    @BindView(R.id.asfnc_titlebar)
    TitleBarUIComponent mTitleBarUIComponent;
    @BindView(R.id.asfnc_title)
    TextView title;
    @BindView(R.id.asfnc_desc)
    TextView desc;
    @BindView(R.id.asfnc_loan_market)
    ImageView loanMarket;

    public static void start(Context context, String cateId, String code, String pageSource) {
        Bundle bundle = new Bundle();
        bundle.putString(InfoConstant.CATE_ID, cateId);
        bundle.putString("code", code);
        bundle.putString(InfoConstant.PAGE_SOURCE, pageSource);
        FRStartActivity.start(context, StatusForNonCompliantActivity.class, bundle);
    }

    @Override
    protected void initView() {
        super.initView();
        FRStatusBar.setTranslucentForImageView(this, findViewById(R.id.asfnc_rootview));
        initTitleBar();
        loanMarket.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FundAndActivityCenterUrlBean fundAndActivityCenterUrlBean = FundAndActivityCenterUrlDao.getInstance().queryObject();
                if (fundAndActivityCenterUrlBean != null && !TextUtils.isEmpty(fundAndActivityCenterUrlBean.getOther_loan_url())) {
                    WebViewActivity.start(getActivity(), fundAndActivityCenterUrlBean.getOther_loan_url());
                }

            }
        });
    }

    @Override
    protected void parseData(ApplySuccessBean data) {
        title.setText(data.getPage_msg().getBig_title());
        desc.setText(data.getPage_msg().getSmall_title());
    }

    private void initTitleBar() {
        mTitleBarUIComponent.initLeftBack(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mTitleBarUIComponent.initTitle(InfoConstant.FUND_CATE_ID.equals(mCateId) ? "公积金验证" : "信用卡验证");

    }

    @Override
    protected int layoutRes() {
        return R.layout.activity_status_for_non_compliant;
    }
}
